﻿namespace Utils
{
    public static class Log
    {
        #region 写日志
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="msg"></param>
        public static void WriteLog(string ClassName, string msg)
        {
            try
            {
                if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Log\\"))
                {
                    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\Log\\");
                }
                string logPath = AppDomain.CurrentDomain.BaseDirectory + "\\Log\\Log_" + DateTime.Now.ToString("yyyy-MM-dd") + ".Log";
                using (System.IO.StreamWriter sw = System.IO.File.AppendText(logPath))
                {
                    sw.WriteLine($"Class:{ClassName}{DateTime.Now.ToString("【yyyy-MM-dd HH:mm:ss】")}:{msg}");
                    sw.Close();
                }
            }
            catch { }
        }
        #endregion
    }
}